import axios from "axios";




// 创建 Axios 实例
const instance = axios.create({
    baseURL: '/api',
    timeout: 10000,
    headers: {
        'X-Custom-Header': 'foobar',
        'Content-Type': 'application/json'
    }
});



export const  getBorrow =async (userName) => {
    try {
        const response = await instance.post('/getBorrow',userName)
        console.log('接口返回数据:', response.data);
        return response.data;
    } catch (error) {
        console.error('查找图书失败:', error);
        throw error;
    }
}


export const  BorrowBook =async (borrowData) => {
    try {
        const response = await instance.post('/BorrowBook',borrowData)
        console.log('接口返回数据:', response.data);
        return response.data;
    } catch (error) {
        console.error('查找图书失败:', error);
        throw error;
    }
}
export const  returnBook =async (borrowData) => {
    try {
        const response = await instance.post('/returnBook',borrowData)
        console.log('接口返回数据:', response.data);

    } catch (error) {
        console.error('查找图书失败:', error);
        throw error;
    }
}
export const  updateStatus =async (borrowData) => {
    try {
        const response = await instance.post('/updateStatus',borrowData)
        console.log('接口返回数据:', response.data);
    } catch (error) {
        console.error('查找图书失败:', error);
        throw error;
    }
}


export default instance;